using System;
using System.Collections.Generic;
using System.Data;

using SMSGateway.Entities.Utils;
using SMSGateway.Entities.Models;
using SMSGateway.DAL;
using SMSGateway.Common;

namespace SMSGateway.Biz
{
	public class AuthorService
	{
		/// <summary>
		/// Saves a record to the tblAuthor table.
		/// </summary>
		public virtual void Insert(AuthorInfo authorInfo)
		{
			try
			{
				new AuthorDAO().Insert(authorInfo);
			}
			catch (Exception ex)
			{
				Logger.Error("SMSGateway.Biz.Author - Insert", ex);
				throw;
			}

		}

		/// <summary>
		/// Saves a record to the tblAuthor table.
		/// </summary>
		public virtual void Update(AuthorInfo authorInfo)
		{
			try
			{
				new AuthorDAO().Update(authorInfo);
			}
			catch (Exception ex)
			{
				Logger.Error("SMSGateway.Biz.Author - Update", ex);
                throw;
			}

		}

		/// <summary>
		/// Delete a record from the tblAuthor table.
		/// </summary>
		public virtual void Delete(string userName)
		{
			try
			{
				new AuthorDAO().Delete(userName);
			}
			catch (Exception ex)
			{
				Logger.Error("SMSGateway.Biz.Author - Delete", ex);
				throw;
			}

		}

		/// <summary>
		/// Selects a single record from the tblAuthor table.
		/// </summary>
		public virtual AuthorInfo Select(string userName)
		{
			try
			{
				return new AuthorDAO().Select(userName);
			}
			catch (Exception ex)
			{
				Logger.Error("SMSGateway.Biz.Author - Select", ex);
				throw;
			}

		}

		/// <summary>
		/// Selects all records from the tblAuthor table.
		/// </summary>
		public List<AuthorInfo> SelectAll()
		{
			try
			{
				return new AuthorDAO().SelectAll();
			}
			catch (Exception ex)
			{
				Logger.Error("SMSGateway.Biz.Author - SelectAll", ex);
				throw;
			}
		}

        /// <summary>
        /// Selects with username records from the tblAuthor table.
        /// </summary>
        public List<AuthorInfo> SelectWithUserName(string userName)
        {
            try
            {
                return new AuthorDAO().SelectWithUserName(userName);
            }
            catch (Exception ex)
            {
                Logger.Error("SMSGateway.Biz.Author - SelectWithUserName", ex);
                throw;
            }
        }

	}
}
